<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bai 2.16</title>
</head>

<body>
<?php
	if(isset($_POST['thang']) && isset($_POST['nam']))
	{		
		$thang=$_POST['thang'];
		$nam=$_POST['nam'];		
		switch($thang)
		{			
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:
				$ngay=31;break;
			case 4:
			case 6:
			case 9:
			case 11:
				$ngay=30;break;
			case 2:
				if($nam%400==0|| ($nam%4==0 && $nam%100!=0))				
					$ngay=29;
				else
					$ngay=28;
				break;					
		}
		$kq="Tháng $thang năm $nam có $ngay ngày";
	}
?>
<form id="form1" name="form1" method="post" action="Bai2_16.php">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr bgcolor="#FF66CC">
      <td style="text-align: center; font-weight: bold; font-style: italic; color: #FFF; font-size: 24px;">TÍNH NGÀY TRONG THÁNG</td>
    </tr>
    <tr bgcolor="#FF99CC">
      <td style="text-align: center">Tháng/năm: 
        
        <input name="thang" type="text" id="thang" value="<?php echo $_POST['thang'];?>" size="6" />
/
<input name="nam" type="text" id="nam" value="<?php echo $_POST['nam'];?>" size="6" /> <input type="submit" name="submit" id="submit" value="Tính số ngày" /></td>
    </tr>
    <tr bgcolor="#FFCCFF">
      <td style="text-align: center"><input style="background-color:#FFC; text-align:center;color:#F36; font-weight:bold" name="kq" type="text" id="kq" value="<?php echo $kq;?>" size="55" readonly="readonly" /></td>
    </tr>
  </table>
</form>
</body>
</html>